home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / ftn / fsigfpe.z / fsigfpe
Encoding:
Text File  |  1998-10-30  |  48.2 KB  |  1,468 lines

  1.  
  2.  
  3.  
  4. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      handle_sigfpes - floating-point exception handler package
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<ffffssssiiiiggggffffppppeeee....hhhh>>>>
  13.  
  14.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee
  15.      hhhhaaaannnnddddlllleeee____ssssiiiiggggffffppppeeeessss((((oooonnnnooooffffffff,,,,eeeennnn____mmmmaaaasssskkkk,,,,uuuusssseeeerrrr____rrrroooouuuuttttiiiinnnneeee,,,,aaaabbbboooorrrrtttt____aaaaccccttttiiiioooonnnn,,,,aaaabbbboooorrrrtttt____rrrroooouuuuttttiiiinnnneeee))))
  16.      iiiinnnntttteeeeggggeeeerrrr ****4444 oooonnnnooooffffffff,,,, eeeennnn____mmmmaaaasssskkkk,,,, aaaabbbboooorrrrtttt____aaaaccccttttiiiioooonnnn
  17.      iiiinnnntttteeeeggggeeeerrrr ****4444 aaaabbbboooorrrrtttt____rrrroooouuuuttttiiiinnnneeee,,,, uuuusssseeeerrrr____rrrroooouuuuttttiiiinnnneeee
  18.      eeeexxxxtttteeeerrrrnnnnaaaallll aaaabbbboooorrrrtttt____rrrroooouuuuttttiiiinnnneeee,,,, uuuusssseeeerrrr____rrrroooouuuuttttiiiinnnneeee
  19.  
  20.      ssssttttrrrruuuuccccttttuuuurrrreeee ////ssssiiiiggggffffppppeeee____tttteeeemmmmppppllllaaaatttteeee////
  21.      iiiinnnntttteeeeggggeeeerrrr **** 4444 rrrreeeeppppllllssss
  22.      iiiinnnntttteeeeggggeeeerrrr **** 4444 ccccoooouuuunnnntttt
  23.      iiiinnnntttteeeeggggeeeerrrr **** 4444 ttttrrrraaaacccceeee
  24.      iiiinnnntttteeeeggggeeeerrrr **** 4444 aaaabbbboooorrrrtttt
  25.      iiiinnnntttteeeeggggeeeerrrr **** 4444 eeeexxxxiiiitttt
  26.      eeeennnndddd ssssttttrrrruuuuccccttttuuuurrrreeee
  27.  
  28.      rrrreeeeccccoooorrrrdddd ////ssssiiiiggggffffppppeeee____tttteeeemmmmppppllllaaaatttteeee//// ffffssssiiiiggggffffppppeeee ((((0000::::FFFFPPPPEEEE____NNNN____EEEEXXXXCCCCEEEEPPPPTTTTIIIIOOOONNNN____TTTTYYYYPPPPEEEESSSS))))
  29.  
  30.      ccccoooommmmmmmmoooonnnn //// ssssiiiiggggffffppppeeee //// ffffssssiiiiggggffffppppeeee ((((0000::::FFFFPPPPEEEE____NNNN____EEEEXXXXCCCCEEEEPPPPTTTTIIIIOOOONNNN____TTTTYYYYPPPPEEEESSSS))))
  31.  
  32.      iiiinnnntttteeeeggggeeeerrrr **** 4444 rrrreeeessssuuuullllttttssss((((0000::::FFFFPPPPEEEE____NNNN____IIIINNNNVVVVAAAALLLLIIIIDDDDOOOOPPPP____RRRREEEESSSSUUUULLLLTTTTSSSS))))
  33.      ccccoooommmmmmmmoooonnnn //// iiiinnnnvvvvaaaalllliiiiddddoooopppp____rrrreeeessssuuuullllttttssss //// rrrreeeessssuuuullllttttssss
  34.  
  35.      iiiinnnntttteeeeggggeeeerrrr **** 4444 iiiinnnnvvvvoooopppp((((0000::::FFFFPPPPEEEE____NNNN____IIIINNNNVVVVAAAALLLLIIIIDDDDOOOOPPPP____OOOOPPPPEEEERRRRAAAANNNNDDDDSSSS))))
  36.      ccccoooommmmmmmmoooonnnn //// iiiinnnnvvvvaaaalllliiiiddddoooopppp____ooooppppeeeerrrraaaannnnddddssss //// iiiinnnnvvvvoooopppp
  37.  
  38.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee uuuusssseeeerrrr____rrrroooouuuuttttiiiinnnneeee ((((ccccoooonnnntttteeeexxxxtttt,,,, rrrreeeessssuuuulllltttt))))
  39.      iiiinnnntttteeeeggggeeeerrrr **** 4444 ccccoooonnnntttteeeexxxxtttt ((((5555))))
  40.      iiiinnnntttteeeeggggeeeerrrr **** 4444 rrrreeeessssuuuulllltttt ((((2222))))
  41.  
  42.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee aaaabbbboooorrrrtttt____rrrroooouuuuttttiiiinnnneeee ((((ppppcccc))))
  43.      iiiinnnntttteeeeggggeeeerrrr **** 4444 ppppcccc
  44.  
  45.  
  46.      For 64 bit programs, use the following prototype for abort_routine:
  47.  
  48.      ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee aaaabbbboooorrrrtttt____rrrroooouuuuttttiiiinnnneeee ((((ppppcccc))))
  49.      iiiinnnntttteeeeggggeeeerrrr **** 8888 ppppcccc
  50.  
  51.  
  52. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  53.      The MIPS floating-point accelerator may raise floating-point exceptions,
  54.      signal SIGFPE, due to five conditions:  FFFFPPPPEEEE____OOOOVVVVEEEERRRRFFFFLLLL(_o_v_e_r_f_l_o_w),
  55.      FFFFPPPPEEEE____UUUUNNNNDDDDEEEERRRRFFFFLLLL(_u_n_d_e_r_f_l_o_w), FFFFPPPPEEEE____DDDDIIIIVVVVZZZZEEEERRRROOOO(_d_i_v_i_d_e-_b_y-_z_e_r_o), FFFFPPPPEEEE____IIIINNNNEEEEXXXXAAAACCCCTTTT(_i_n_e_x_a_c_t
  56.      _r_e_s_u_l_t), or FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD(_i_n_v_a_l_i_d _o_p_e_r_a_n_d, e.g., infinity). Usually these
  57.      conditions are masked, and do not cause a floating-point exception.
  58.      Instead, a default value is substituted for the result of the operation,
  59.      and the program continues silently. This event may be intercepted by
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  71.  
  72.  
  73.  
  74.      causing an exception to be raised.  When this occurs, the operating
  75.      system generates a SIGFPE signal.
  76.  
  77.      The integer arithmetic instructions add, addi, dadd, daddi, sub, and dsub
  78.      also generate a SIGFPE signal when the result of the operation overflows
  79.      (condition FFFFPPPPEEEE____IIIINNNNTTTT____OOOOVVVVEEEERRRRFFFFLLLL(_i_n_t_e_g_e_r _o_v_e_r_f_l_o_w)).  (At the moment, SGI
  80.      compilers generate only unsigned versions of these instructions, which do
  81.      not generate a signal on overflow.  However it is still possible to
  82.      generate these instructions via assembly language).
  83.  
  84.      Once an exception is raised, the specific conditions which caused the
  85.      exception may be determined, and more appropriate action taken.
  86.  
  87.      The library lllliiiibbbbffffppppeeee....ssssoooo provides two methods to unmask and handle these
  88.      conditions: the subroutine hhhhaaaannnnddddlllleeee____ssssiiiiggggffffppppeeeessss, and the environment variable
  89.      TTTTRRRRAAAAPPPP____FFFFPPPPEEEE.  Both methods provide a mechanism for unmasking each condition
  90.      except FFFFPPPPEEEE____IIIINNNNEEEEXXXXAAAACCCCTTTT, for _h_a_n_d_l_i_n_g and classifying exceptions arising from
  91.      them, and for substituting either a default value or a chosen one.  They
  92.      also provide mechanisms to count, trace, exit or abort on enabled
  93.      exceptions.  If the user supplies his own call to hhhhaaaannnnddddlllleeee____ssssiiiiggggffffppppeeeessss he
  94.      should leave environment variable TTTTRRRRAAAAPPPP____FFFFPPPPEEEE undefined or set to OFF.
  95.      TTTTRRRRAAAAPPPP____FFFFPPPPEEEE is supported for Fortran, C and Pascal.  HHHHaaaannnnddddlllleeee____ssssiiiiggggffffppppeeeessss is
  96.      supported for C and Fortran.
  97.  
  98.      Calling the subroutine is the preferred method when preparing software
  99.      for others to use, since it relieves the user of any need to know about
  100.      the TTTTRRRRAAAAPPPP____FFFFPPPPEEEE environment variable.
  101.  
  102.      The environment variable is preferable if one wants to experiment or
  103.      allow any user to experiment with with different trap behaviors with
  104.      minimum effort.
  105.  
  106.      Libfpe uses System V signal handling and will not work with programs
  107.      which use Berkeley signal handling.
  108.  
  109.      Note that the preferred method for flushing denormals to zero is to set
  110.      the FS bit to 1 in the floating point control status register.  The
  111.      following routine (written in c) can be used to set/clear the FS bit.
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  137.  
  138.  
  139.  
  140.           #include <sys/fpu.h>
  141.  
  142.           void
  143.           flush_to_zero_(int *on_off)
  144.           {
  145.           union fpc_csr   n;
  146.  
  147.                n.fc_word = get_fpc_csr();
  148.  
  149.                if ( (*on_off) == 0 ) {
  150.  
  151.                     n.fc_struct.flush = 0;
  152.  
  153.                } else {
  154.  
  155.                     n.fc_struct.flush = 1;
  156.  
  157.                }
  158.  
  159.                set_fpc_csr(n.fc_word);
  160.           }
  161.  
  162.      Example:
  163.  
  164.           integer flag
  165.  
  166.      c    enable flush to zero
  167.  
  168.           flag = 1
  169.  
  170.           call flush_to_zero( flag )
  171.  
  172.      Note that if the FS bit in the floating point control status register is
  173.      set, it remains set after calling handle_sigfpes(FPE_OFF, ...
  174.  
  175.      Be sure to read the section NOTES FOR R8000, below, which describes the
  176.      behavior of libfpe.so on the R8000 processor.
  177.  
  178. HHHHAAAANNNNDDDDLLLLEEEE____SSSSIIIIGGGGFFFFPPPPEEEESSSS SSSSUUUUBBBBRRRROOOOUUUUTTTTIIIINNNNEEEE
  179.      The values in the global arrays are described in the section WWWWHHHHEEEENNNN AAAANNNN
  180.      EEEEXXXXCCCCEEEEPPPPTTTTIIIIOOOONNNN IIIISSSS EEEENNNNCCCCOOOOUUUUNNNNTTTTEEEERRRREEEEDDDD later in this man page.
  181.  
  182.      The arguments to _h_a_n_d_l_e__s_i_g_f_p_e_s are as follows:
  183.  
  184.      _o_n_o_f_f is a flag indicating whether handling is being turned on (_o_n_o_f_f ==
  185.      _F_P_E__O_N) or off (_o_n_o_f_f == _F_P_E__O_F_F). (_o_n_o_f_f == _F_P_E__D_E_B_U_G) is another way to
  186.      turn on handling.  Information from the fsigfpe structure will be printed
  187.      if (_o_n_o_f_f == _F_P_E__D_E_B_U_G).  (all the names used in this document are
  188.      defined in _f_s_i_g_f_p_e._h).
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  203.  
  204.  
  205.  
  206.      _e_n__m_a_s_k indicates which of the five conditions should be unmasked,
  207.      enabling them to raise floating-point exceptions. _e_n__m_a_s_k is only valid
  208.      if onoff == FPE_ON or onoff == FPE_DEBUG, and is the bitwise or of one or
  209.      more of the constants FPE_EN_UNDERFL, FPE_EN_OVERFL, FPE_EN_DIVZERO,
  210.      FPE_EN_INVALID, and FPE_EN_INT_OVERFL (defined in _f_s_i_g_f_p_e._h).
  211.  
  212.      _u_s_e_r__r_o_u_t_i_n_e: hhhhaaaannnnddddlllleeee____ssssiiiiggggffffppppeeeessss provides a mechanism for setting the result
  213.      of the operation to any one of a set of well-known values.  If full
  214.      control over the value of selected operations is desired for one or more
  215.      exception conditions, a subroutine _u_s_e_r__r_o_u_t_i_n_e must be provided.  For
  216.      these selected exception conditions, _u_s_e_r__r_o_u_t_i_n_e will be called to set
  217.      the value resulting from the operation.  Pass a 0 (plain 0 is adequate)
  218.      if you do not wish to provide a _u_s_e_r__r_o_u_t_i_n_e .
  219.  
  220.      _a_b_o_r_t__a_c_t_i_o_n: If the handler encounters an unexpected condition, an
  221.      inconsistency, or begins looping, the flag _a_b_o_r_t__a_c_t_i_o_n indicates what
  222.      action should be taken.  Another option is for the user to specify that
  223.      he is supplying his own floating point exception handler as the default
  224.      handler.
  225.  
  226.      Legal values are:
  227.  
  228.            ____________________________________________________________
  229.                                             instruct the floating-
  230.                                             point-accelerator to cease
  231.                                             causing exceptions and
  232.                                             continue.  (i.e., disable
  233.                                             handling)
  234.             FPE_TURN_OFF_HANDLER_ON_ERROR
  235.  
  236.  
  237.  
  238.  
  239.            ____________________________________________________________
  240.                                             kill the process after
  241.                                             giving an error message
  242.                                             and calling a user-
  243.                                             supplied cleanup routine
  244.                                             if one is provided via the
  245.                                             abort_routine parameter.
  246.                        FPE_ABORT_ON_ERROR
  247.  
  248.  
  249.  
  250.  
  251.  
  252.            ____________________________________________________________
  253.                                             install the indicated user
  254.                                             routine as the handler
  255.                                             when such an error is
  256.                                             encountered.  Future
  257.                                             floating-point exceptions
  258.                                             will branch to the user-
  259.                                             routine. (see signal(2))
  260.              FPE_REPLACE_HANDLER_ON_ERROR
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.            ____________________________________________________________
  268.                                             install the indicated user
  269.                                             routine as the handler
  270.                                             immediately.  Future
  271.                                             floating-point exceptions
  272.                                             will branch to the user-
  273.                                             routine. (see signal(2))
  274.                                             |||||||||||||||||||||||||||
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.                                                                                                         |||||||||||||||||||||||||||
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.                                                                         PPPPaaaaggggeeee 4444
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  340.  
  341.  
  342.  
  343.                          FPE_USER_HANDLER
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.            ||||||||||||||||||||||||||||||||||||||||||||||||||
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.                                                                        ||||||||||||||||||||||||||||||||||||||||||||||||||
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.                                                                         PPPPaaaaggggeeee 5555
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  505.  
  506.  
  507.  
  508.           _____________________________________________________________
  509.            |
  510.                                                                        |
  511.  
  512.      _a_b_o_r_t__r_o_u_t_i_n_e: When a fatal error (i.e., one described under _a_b_o_r_t__a_c_t_i_o_n
  513.      above) is encountered, _a_b_o_r_t__r_o_u_t_i_n_e is used as the address of a user
  514.      subroutine.
  515.  
  516.      If abort_action is FPE_ABORT_ON_ERROR, and _a_b_o_r_t__r_o_u_t_i_n_e is valid, it is
  517.      called before aborting, and passed a pointer to the instruction causing
  518.      the exception as its single argument.  In this case, the user's
  519.      abort_routine should be defined as
  520.  
  521.                            subroutine abort_routine(pc)
  522.                                    integer *4 pc
  523.  
  524.      for 32 bit programs.  (Use integer *8 for 64 bit programs.)
  525.  
  526.      If _a_b_o_r_t__a_c_t_i_o_n is FPE_REPLACE_HANDLER_ON_ERROR, and _a_b_o_r_t__r_o_u_t_i_n_e is
  527.      valid, it will be installed as the new handler.  In this case, the
  528.      instruction which caused the unexpected exception will be re-executed,
  529.      causing a new exception, and _a_b_o_r_t__r_o_u_t_i_n_e entered.  Pass a %val(0) if
  530.      you do not wish to provide an _a_b_o_r_t__a_c_t_i_o_n routine.
  531.  
  532.      If _a_b_o_r_t__a_c_t_i_o_n is FPE_USER_HANDLER, and _a_b_o_r_t__r_o_u_t_i_n_e is valid, it will
  533.      be installed immediately as the default floating point exception handler.
  534.  
  535.      If the user routine is to be invoked as a floating point exception
  536.      handler, the following prototype (written in c) should be used (see
  537.      <sigfpe.h> and signal(5)):
  538.  
  539.      int user_handler( sig, code, sc )
  540.      int sig, code;
  541.      struct sigcontext *sc;
  542.  
  543.      Routine user_handler should return 0 to continue processing of the user's
  544.      code and a non-zero value to disconnect user_handler as the floating
  545.      point exception handler.  User_handler should not issue a call to
  546.      signal(), nor should it update the program counter in the sigcontext
  547.      area, because these actions are done in the routine which calls it.  A
  548.      user handler can determine which type of exception has occurred by
  549.      calling routine __fpe_trap_type().  This routine returns one of
  550.      FPE_UNDERFL, FPE_OVERFL, etc. as appropriate.
  551.  
  552.      Users can supply separate handlers for each exception type by making
  553.      multiple calls to handle_sigfpes.  See the third example below.
  554.      Similarly, trap handling for one or more exception types can be turned
  555.      off by or-ing the appropriate combination of masks in the second
  556.      parameter to handle_sigfpes.
  557.  
  558.      call handle_sigfpes(FPE_OFF, 0, ...
  559.  
  560.      disables handling of all SIGFPE signals.
  561.  
  562.  
  563.                                                                         PPPPaaaaggggeeee 6666
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  571.  
  572.  
  573.  
  574. EEEEXXXXAAAAMMMMPPPPLLLLEEEE OOOOFFFF HHHHAAAANNNNDDDDLLLLEEEE____SSSSIIIIGGGGFFFFPPPPEEEESSSS
  575.           #include <fsigfpe.h>
  576.           C     call this during program startup
  577.           C     to set underflowing values to zero
  578.           C
  579.           C     underflow to zero
  580.  
  581.                 fsigfpe(FPE_UNDERFL).repls = FPE_ZERO
  582.           C
  583.           C     only trap on underflow
  584.                 handle_sigfpes(_ON, FPE_EN_UNDERFL , %val(0), FPE_ABORT_ON_ERROR, %val(0));
  585.  
  586.      The above example does one thing only: it sets up traps of underflow
  587.      which change the resulting value to zero.
  588.  
  589.      The following is a more complicated example.
  590.  
  591.           #include <fsigfpe.h>
  592.           C   underflow to zero
  593.  
  594.                 fsigfpe(FPE_UNDERFL).repls = FPE_ZERO
  595.  
  596.           C     substitute max real/double precision value on overflow
  597.  
  598.                 fsigfpe(FPE_OVERFL).repls=FPE_MAX
  599.  
  600.           C     trace after 5
  601.  
  602.                 fsigfpe(FPE_UNDERFL).trace=5
  603.                 fsigfpe(FPE_OVERFL).trace =5
  604.                 fsigfpe(FPE_DIVZERO).trace=5
  605.                 fsigfpe(FPE_INVALID).trace=5
  606.                 fsigfpe(FPE_INT_OVERFL).trace=5
  607.  
  608.           C     counts at end
  609.  
  610.                 fsigfpe(FPE_UNDERFL).count=2147483647
  611.                 fsigfpe(FPE_OVERFL).count =2147483647
  612.                 fsigfpe(FPE_DIVZERO).count=2147483647
  613.                 fsigfpe(FPE_INVALID).count=2147483647
  614.                 fsigfpe(FPE_INT_OVERFL).count=2147483647
  615.  
  616.           C     abort after 100 underflows or 100 overflows
  617.  
  618.                 fsigfpe(FPE_UNDERFL).abort=100
  619.                 fsigfpe(FPE_OVERFL).abort =100
  620.  
  621.           C     abort on first divide by zero or hundredth invalid
  622.  
  623.                 fsigfpe(FPE_DIVZERO).abort=1
  624.                 fsigfpe(FPE_INVALID).abort=100
  625.  
  626.  
  627.  
  628.  
  629.                                                                         PPPPaaaaggggeeee 7777
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  637.  
  638.  
  639.  
  640.                 call handle_sigfpes(FPE_ON,
  641.                x                    FPE_EN_UNDERFL +  FPE_EN_OVERFL +
  642.                x                    FPE_EN_DIVZERO +  FPE_EN_INVALID,
  643.                x                    %val(0),
  644.                x                    FPE_ABORT_ON_ERROR,
  645.                x                    %val(0))
  646.  
  647.           C    do the real application work here
  648.  
  649.           The example counts all traps, traces the first five
  650.           exceptions of each kind, aborts on the first divide
  651.           by zero, or the 100th overflow.  It replaces zero for
  652.           underflows, max float/double for overflows, max integer
  653.           for integer overflows, and the default values for
  654.           divide by zero, invalid operands, and integer overflows.
  655.           The environment variable example below does the same thing.
  656.  
  657.           The last example shows how to enable different handlers
  658.           for  various exception types.
  659.  
  660.                  #include <fsigfpe.h>
  661.  
  662.                      external                my_invalid_handler
  663.  
  664.                  c counts at end
  665.  
  666.                      fsigfpe(FPE_UNDERFL).count=2147483647
  667.                      fsigfpe(FPE_OVERFL).count =2147483647
  668.                      fsigfpe(FPE_DIVZERO).count=2147483647
  669.                      fsigfpe(FPE_INVALID).count=2147483647
  670.                      fsigfpe(FPE_INT_OVERFL).count=2147483647
  671.  
  672.                  c enable trapping on overflow, using libfpe's trap handler
  673.  
  674.                      call handle_sigfpes(FPE_ON, FPE_EN_OVERFL, 0, 0, 0)
  675.  
  676.                  c enable trapping on invalid, using user's own trap handler
  677.  
  678.                      call handle_sigfpes(FPE_ON, FPE_EN_INVALID, my_invalid_handler, 0, 0)
  679.  
  680.                  c do the real application work here
  681.  
  682.                  ...
  683.  
  684.                  c turn off trapping of overflows
  685.  
  686.                      call handle_sigfpes(FPE_OFF, FPE_EN_OVERFL, 0, 0, 0)
  687.  
  688.                  ...
  689.  
  690.                  c turn off all handling of SIGFPE signals
  691.  
  692.  
  693.  
  694.  
  695.                                                                         PPPPaaaaggggeeee 8888
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  703.  
  704.  
  705.  
  706.                      call handle_sigfpes(FPE_OFF, 0, 0, 0, 0)
  707.  
  708. TTTTHHHHEEEE EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT VVVVAAAARRRRIIIIAAAABBBBLLLLEEEE TTTTRRRRAAAAPPPP____FFFFPPPPEEEE
  709.      If the code has been linked with lllliiiibbbbffffppppeeee....ssssoooo the runtime startup routine
  710.      will check for the environment variable "TTTTRRRRAAAAPPPP____FFFFPPPPEEEE".  The string read as
  711.      the value of TTTTRRRRAAAAPPPP____FFFFPPPPEEEE will be interpreted and hhhhaaaannnnddddlllleeee____ssssiiiiggggffffppppeeeessss will be
  712.      called with the resulting values.
  713.  
  714.      TTTTRRRRAAAAPPPP____FFFFPPPPEEEE is read in upper case letters only. The string assigned to
  715.      TTTTRRRRAAAAPPPP____FFFFPPPPEEEE may be in upper case or lower case.  TTTTRRRRAAAAPPPP____FFFFPPPPEEEE can take one of
  716.      two forms: either a global value, or a list of individual items.
  717.  
  718.      global values:
  719.  
  720.                                 Execute the program with no
  721.                                 trap handling enabled.  Same as
  722.                                 TTTTRRRRAAAAPPPP____FFFFPPPPEEEE undefined.  Same as
  723.                                 linking without libfpe.so
  724.                     "" or OFF
  725.  
  726.  
  727.  
  728.                            ON   Same as TTTTRRRRAAAAPPPP____FFFFPPPPEEEE====""""AAAALLLLLLLL====DDDDEEEEFFFFAAAAUUUULLLLTTTT"""".
  729.      Alternately, replacement values and actions may be specified for each of
  730.      the possible trap types individually.  This is accomplished by setting
  731.      the environment variable as follows:
  732.  
  733.      setenv TTTTRRRRAAAAPPPP____FFFFPPPPEEEE "item;item;item...."
  734.  
  735.      an item can be one of the following:
  736.  
  737.                                        Where traptype defines the
  738.                                        specific floating point
  739.                                        exception to enable, and
  740.                                        statuslist defines the
  741.                                        list of actions upon
  742.                                        encountering the trap.
  743.                  traptype=statuslist
  744.  
  745.  
  746.  
  747.  
  748.  
  749.                                        Confirm the parsing of the
  750.                                        environment variable, and
  751.                                        the trap actions.
  752.                                DEBUG
  753.  
  754.  
  755.      Traptype can be one of the following literal strings:
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.                                                                         PPPPaaaaggggeeee 9999
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  781.  
  782.  
  783.  
  784.                                       UNDERFL   underflow
  785.                                        OVERFL   overflow
  786.                                       DIVZERO   divide by zero
  787.                                       INVALID   invalid operand
  788.                   INT_OVERFL integer overflow
  789.                                           ALL   all of the above
  790.      Statuslist is a list separated by commas.  It contains an optional
  791.      symbolic replacement value, and an optional list of actions.
  792.  
  793.      symbolic replacement values:
  794.  
  795.       DEFAULT   Do not override the predefined default values.
  796.          IEEE   Maps to integer code FPE_APPROPRIATE.
  797.   APPROPRIATE   Maps to integer code FPE_APPROPRIATE.
  798.          ZERO   Maps to integer code FPE_ZERO.
  799.    FLUSH_ZERO   Maps to integer code FPE_FLUSH_ZERO (R4000 and later processors).
  800.    FLUSH_ZERO   Maps to integer code FPE_ZERO (other processors).
  801.           MIN   Maps to integer code FPE_MIN.
  802.           MAX   Maps to integer code FPE_MAX.
  803.           INF   Maps to integer code FPE_INF.
  804.           NAN   Maps to integer code FPE_NAN.
  805.  
  806.  
  807.  
  808.  
  809.  
  810.      All actions take an optional integer in parentheses:
  811.  
  812.      Note: for any traps that have an action and no specified replacement
  813.      value, the DEFAULT replacement value will be used.
  814.  
  815.                                   A count of the trap type
  816.                                   will be printed to stderr
  817.                                   every nth trap, and at the
  818.                                   end of the program.
  819.                                   Default is INT_MAX.
  820.                        COUNT(n)
  821.  
  822.  
  823.  
  824.  
  825.  
  826.                                   Core dump and abort the
  827.                                   program upon encountering
  828.                                   the nth trap.  Default is
  829.                                   1.
  830.                        ABORT(n)
  831.  
  832.  
  833.  
  834.  
  835.                                   Exit program upon
  836.                                   encountering the nth trap.
  837.                                   Default is 1.
  838.                         EXIT(n)
  839.  
  840.  
  841.  
  842.                                   If a trap is encountered,
  843.                                   Print a stack trace to
  844.                                   stderr up to n times.
  845.                                   Default is 10.
  846.                        TRACE(n)
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.                                                                        PPPPaaaaggggeeee 11110000
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  861.  
  862.  
  863.  
  864. EEEEXXXXAAAAMMMMPPPPLLLLEEEE OOOOFFFF TTTTRRRRAAAAPPPP____FFFFPPPPEEEE
  865.      setenv TTTTRRRRAAAAPPPP____FFFFPPPPEEEE "ALL=COUNT; UNDERFL=ZERO; OVERFL=TRACE(5), ABORT(100);
  866.      DIVZERO=ABORT"
  867.  
  868.      The example counts all traps, trace the first five overflows, abort on
  869.      the first divide by zero, or the 100th overflow.  It Replaces zero for
  870.      underflows, the "appropriate" value for overflows, divide by zero, and
  871.      invalid operands.
  872.  
  873. WWWWHHHHEEEENNNN AAAANNNN EEEEXXXXCCCCEEEEPPPPTTTTIIIIOOOONNNN IIIISSSS EEEENNNNCCCCOOOOUUUUNNNNTTTTEEEERRRREEEEDDDD
  874.      When an exception is encountered, the handler examines the instruction
  875.      causing the exception, the state of the floating-point accelerator and
  876.      the sigfpe structure to determine the correct action to take, and the
  877.      program is continued.  In the cases of FFFFPPPPEEEE____UUUUNNNNDDDDEEEERRRRFFFFLLLL,,,, FFFFPPPPEEEE____OOOOVVVVEEEERRRRFFFFLLLL,,,,
  878.      FFFFPPPPEEEE____DDDDIIIIVVVVZZZZEEEERRRROOOO,,,, and some instances of FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD,,,, an appropriate value is
  879.      substituted for the result of the operation, and the instruction which
  880.      caused the exception is skipped.  For most exceptions arising due to an
  881.      invalid operand (FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD exceptions), more meaningful behavior may be
  882.      obtained by replacing an erroneous operand.  For these conditions, the
  883.      operand is replaced, and the instruction re-issued.
  884.  
  885.      _s_i_g_f_p_e: For each enabled exception, the sigfpe structure contains the
  886.      fields: repls, count, trace, exit and abort. For each enabled exception
  887.      <p>, and each non-zero entry <n> in the sigfpe structure, the trap
  888.      handler will take the following actions:
  889.      ccccoooouuuunnnntttt:::: A count of all enabled traps will be printed to stderr at the end
  890.      of execution of the program , and every at <n>th exception <p>.
  891.      ttttrrrraaaacccceeee:::: A dbx stack trace will be printed to stderr every exception <p>,
  892.      up to <n> times.  You must have dbx installed on your system to use this
  893.      option.
  894.      aaaabbbboooorrrrtttt:::: Core dump and abort program upon encountering the <n>th exception
  895.      <p>. The abort option takes precedence over the exit option.
  896.      eeeexxxxiiiitttt:::: Exit program upon encountering the <n>th  exception <p>.  rrrreeeeppppllllssss::::
  897.      Each of the exceptions FFFFPPPPEEEE____UUUUNNNNDDDDEEEERRRRFFFFLLLL, FFFFPPPPEEEE____OOOOVVVVEEEERRRRFFFFLLLL, FFFFPPPPEEEE____DDDDIIIIVVVVZZZZEEEERRRROOOO and
  898.      FFFFPPPPEEEE____IIIINNNNTTTT____OOOOVVVVEEEERRRRFFFFLLLL has an associated default value which is used as the
  899.      result of the operation causing the exception.  These default values may
  900.      be overridden by initializing this integer value.  This value is
  901.      interpreted as an integer code used to select one of a set of replacement
  902.      values, or to indicate that the routine _u_s_e_r__r_o_u_t_i_n_e is responsible for
  903.      setting the value.
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.                                                                        PPPPaaaaggggeeee 11111111
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  927.  
  928.  
  929.  
  930.      These integer codes are listed below:
  931.  
  932.      FPE_ZERO              use zero as the replacement value
  933.  
  934.                            Set the flush_zero bit in the
  935.                            Control Status register.  This
  936.                            causes a flush to zero without
  937.                            invoking the trap handler.  Works
  938.                            only for underflow traps on the
  939.                            R4000 and later processors.
  940.                            Works like FPE_ZERO for the
  941.                            R3000.
  942.      FPE_FLUSH_ZERO
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.                            use the appropriately-typed
  952.                            minimum value as the replacement.
  953.                            (i.e., the smallest number which
  954.                            is representable in that format
  955.                            _w_i_t_h_o_u_t denormalizing)
  956.      FPE_MIN
  957.  
  958.  
  959.  
  960.  
  961.  
  962.                            use the appropriately-typed
  963.                            maximum value as the replacement
  964.      FPE_MAX
  965.  
  966.  
  967.                            use the appropriately-typed value
  968.                            for infinity as the replacement
  969.      FPE_INF
  970.  
  971.  
  972.                            use the appropriately-typed value
  973.                            for not-a-number as the
  974.                            replacement.  (A _q_u_i_e_t not-a-
  975.                            number is used.)
  976.      FPE_NAN
  977.  
  978.  
  979.  
  980.  
  981.                            use IEEE standard results as the
  982.                            return result for FFFFPPPPEEEE____UUUUNNNNDDDDEEEERRRRFFFFLLLL,
  983.                            FFFFPPPPEEEE____OOOOVVVVEEEERRRRFFFFLLLL, FFFFPPPPEEEE____DDDDIIIIVVVVZZZZEEEERRRROOOO, and
  984.                            FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD exceptions.
  985.      FPE_APPROPRIATE
  986.  
  987.  
  988.  
  989.  
  990.                            invoke the routine _u_s_e_r__r_o_u_t_i_n_e
  991.                            (see note) to set the value of
  992.                            the operation.  If this is the
  993.                            code used for FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD
  994.                            exceptions, all such exceptions
  995.                            will defer to _u_s_e_r__r_o_u_t_i_n_e to set
  996.                            their value.  In this case,
  997.                            _i_n_v_a_l_i_d_o_p__r_e_s_u_l_t_s_ and
  998.                            _i_n_v_a_l_i_d_o_p__o_p_e_r_a_n_d_s_ will be
  999.                            ignored.
  1000.      FPE_USER_DETERMINED
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.                            use the negative of the argument
  1012.                            as the replacement operand.  This
  1013.                            code is valid only for the cases
  1014.                            _SQRT_NEG_X and _RSQRT_NEG_X (see
  1015.      FPE_NEG
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.                                                                        PPPPaaaaggggeeee 11112222
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  1032.  
  1033.  
  1034.  
  1035.                            below).
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.      The default values used as the results of floating-point exceptions are:
  1043.  
  1044.              _________________________________________________________
  1045.                             values for _f_s_i_g_f_p_e()._r_e_p_l_s
  1046.                   element
  1047.               #   mnemonic      exception condition   default value
  1048.              _________________________________________________________
  1049.               0   (none)        (ignored)
  1050.               1   FPE_UNDERFL   underflow             FPE_APPROPRIATE
  1051.               2   FPE_OVERFL    overflow              FPE_APPROPRIATE
  1052.               3   FPE_DIVZERO   divide-by-zero        FPE_APPROPRIATE
  1053.               4   FPE_INVALID   invalid operand       0 (use tables)
  1054.              _________________________________________________________
  1055.              ||||||||||
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.                               |||||||||
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.                                                     |||||||||
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.                                                                       ||||||||||
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.      The default values for FPE_OVERFL, FPE_DIVZERO, and FPE_INVALID
  1090.      exceptions will produce the same results as if the instruction were re-
  1091.      issued with the original operand(s) and floating-point traps disabled.
  1092.  
  1093.  
  1094.      For FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD exceptions, the correct action may be either to set the
  1095.      result and skip the instruction, or to replace an operand and retry the
  1096.      instruction. There are four cases in which the result is set.  The
  1097.      integer array constituting the named common _i_n_v_a_l_i_d_o_p__r_e_s_u_l_t_s is
  1098.      consulted for replacement codes for these cases:
  1099.  
  1100.      _________________________________________________________________________
  1101.                      array in common block _i_n_v_a_l_i_d_o_p__r_e_s_u_l_t_s
  1102.                    element
  1103.       #   mnemonic                        exception condition   default value
  1104.      _________________________________________________________________________
  1105.       0   (none)                          (ignored)
  1106.       1   FPE_MAGNITUDE_INF_SUBTRACTION   oo - oo               FPE_NAN
  1107.       2   FPE_ZERO_TIMES_INF              0 * oo                FPE_NAN
  1108.       3   FPE_ZERO_DIV_ZERO               0/0                   FPE_NAN
  1109.       4   FPE_INF_DIV_INF                 oo / oo               FPE_NAN
  1110.      _________________________________________________________________________
  1111.      ||||||||||
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.                                         |||||||||
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.                                                               |||||||||
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.                                                                               ||||||||||
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.      There are ten cases in which an offending operand is replaced. An array
  1146.      named _i_n_v_a_l_i_d_o_p__o_p_e_r_a_n_d_s_ is consulted for user-initialized codes for
  1147.      these cases.  Cases 8 through 11 are valid only for the mips3 and later
  1148.      architectures.  Array _i_n_v_a_l_i_d_o_p__o_p_e_r_a_n_d_s_ has only 8 entries (0-7) for
  1149.      the earlier processors.  Each element governs the following cases:
  1150.  
  1151.  
  1152.  
  1153.                                                                        PPPPaaaaggggeeee 11113333
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  1161.  
  1162.  
  1163.  
  1164.     __________________________________________________________________________
  1165.                             array _i_n_v_a_l_i_d_o_p__o_p_e_r_a_n_d_s_
  1166.             element
  1167.      #    mnemonic            exception condition              default value
  1168.     __________________________________________________________________________
  1169.      0    (none)              (ignored)
  1170.      1    FPE_SQRT_NEG_X      sqrt(-x)                         reissue
  1171.      2    (unused)            (ignored)                        with original
  1172.                               conversion to integer caused
  1173.                               target to overflow
  1174.      3    FPE_CVTW_OVERFL                                      operands and
  1175.  
  1176.      4    FPE _CVTW_NAN       conversion of NaN to int         floating point
  1177.      5    FPE_CVTW_INF        conversion of oo to int          traps disabled
  1178.      6    FPE_UNORDERED_CMP   comparison to NaN
  1179.                               operand was Signaling Nan
  1180.      7    FPE_SNAN_OP
  1181.                               conversion to long long caused
  1182.                               target to overflow
  1183.      8    FPE_CVTL_OVERFL
  1184.  
  1185.      9    FPE_CVTL_NAN        conversion of NaN to long long
  1186.      10   FPE_CVTL_INF        conversion of oo to long long
  1187.      11   FPE_RSQRT_NEG_X     reciprocal sqrt(-x)
  1188.     __________________________________________________________________________
  1189.     |||||||||||||||||||
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.                             ||||||||||||||||||
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.                                                              ||||||||||||||||||
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.                                                                               |||||||||||||||||||
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259. NNNNOOOOTTTTEEEE
  1260.      UUUUsssseeee ooooffff _u_s_e_r__r_o_u_t_i_n_e ttttoooo sssseeeetttt vvvvaaaalllluuuueeeessss
  1261.      If the integer code defining the replacement value for a particular
  1262.      exception condition is _USER_DETERMINED, the user-supplied routine
  1263.      _u_s_e_r__r_o_u_t_i_n_e is called:
  1264.                  ccccaaaallllllll uuuusssseeeerrrr____rrrroooouuuuttttiiiinnnneeee((((eeeexxxxcccceeeeppppttttiiiioooonnnn____ppppaaaarrrraaaammmmeeeetttteeeerrrrssss,,,, vvvvaaaalllluuuueeee))))
  1265.      _v_a_l_u_e is an array of two _i_n_t * _4s into which _u_s_e_r__r_o_u_t_i_n_e should store
  1266.      the replacement value.  If an operand is being replaced, _v_a_l_u_e has a copy
  1267.      of the current operand.
  1268.  
  1269.      _e_x_c_e_p_t_i_o_n__p_a_r_a_m_e_t_e_r_s is an array of five _i_n_t * _4s which describe the
  1270.      exception condition:
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.                                                                        PPPPaaaaggggeeee 11114444
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297. FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))                                                        FFFFSSSSIIIIGGGGFFFFPPPPEEEE((((3333FFFF))))
  1298.  
  1299.  
  1300.  
  1301.        ____________________________________________________________________
  1302.                             array _e_x_c_e_p_t_i_o_n__p_a_r_a_m_e_t_e_r_s
  1303.                element
  1304.         #   mnemonic             description
  1305.        ____________________________________________________________________
  1306.         0   FPE_EXCEPTION_TYPE   the exception type (FPE_DIVZERO, etc).
  1307.                                  value = FPE_SET_RESULT if result is
  1308.                                  being set.  value = FPE_REPL_OPERAND
  1309.                                  if an operand is being replaced.  This
  1310.                                  element is meaningful only if the
  1311.                                  exception type is FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD.
  1312.         1   FPE_INVALID_ACTION
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                                  This element is meaningful only if the
  1318.                                  exception type is FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD.  It is
  1319.                                  the index corresponding to the
  1320.                                  particular conditions giving rise to
  1321.                                  the exception.  In conjunction with
  1322.                                  element 1, this value uniquely
  1323.                                  determines the exception condition.
  1324.                                  (e.g., if FPE_INVALID_ACTION is
  1325.                                  FPE_SET_RESULT and FPE_INVALID_TYPE is
  1326.                                  2, the FFFFPPPPEEEE____IIIINNNNVVVVAAAALLLLIIIIDDDD exception is due to
  1327.                                  FPE_ZERO_TIMES_INF.)
  1328.         2   FPE_INVALID_TYPE
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.                                  the type of the replacement value -
  1340.                                  either FPE_SINGLE, FPE_DOUBLE,
  1341.                                  FPE_WORD, or FPE_LONGWORD.
  1342.         3   FPE_VALUE_TYPE
  1343.  
  1344.  
  1345.                                  the suggested sign _u_s_e_r__r_o_u_t_i_n_e should
  1346.                                  use for the replacement value - either
  1347.                                  FPE_POSITIVE or FPE_NEGATIVE.
  1348.         4   FPE_VALUE_SIGN
  1349.  
  1350.  
  1351.        ____________________________________________________________________
  1352.        ||||||||||||||||||||||||||||
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.                                |||||||||||||||||||||||||||
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.                                                                            ||||||||||||||||||||||||||||
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433. NNNNOOOOTTTTEEEESSSS FFFFOOOORRRR RRRR8888000000000000
  1434.      Due to the nature of parallel operations on the R8000 processor, it is
  1435.      not possible to determine the true value of the program counter when a
  1436.      floating point exception occurs.  Therefore, on that processor, libfpe.so
  1437.      will not update either operands or results when floating point exceptions
  1438.      occur.  Another anomaly on this processor is that counts of floating
  1439.      point exceptions for a particular program may vary from run to run.
  1440.  
  1441.      When the R8000 processor executes in precise exception mode, libfpe
  1442.      behaves as it does on other processors, i.e. operands and results can be
  1443.      updated when floating point exceptions occur.  See fpmode(1).
  1444.  
  1445. NNNNOOOOTTTTEEEESSSS
  1446.      Use of the 6.2 beta version of libfpe requires a 6.2 beta operating
  1447.      system (or later version).
  1448.  
  1449.  
  1450. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  1451.      signal(3c), sigfpe(3c), fpc(3c), get_fpc_csr(3c), set_fp_csr(3c)
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.                                                                        PPPPaaaaggggeeee 11115555
  1459.  
  1460.  
  1461.  
  1462.